﻿/* ***************************************************** */
/* Arcans Team (2010), website                           */
/* Site under GNU GPL v3 Licence                         */
/* (see NOTICE and COPYING in the of the site file tree) */
/* ***************************************************** */

/* ***************************************************** */
/* module de gestion du voile                            */
/* ***************************************************** */
var voile = (function () {
	var voile_ex; var voile_P_in; var voile_S_in; var voile_X_in; var voile_af1;
	var voile_af2; var voile_af3; var voile_lg1; var voile_lg2; var voile_verr;
	function init_base_aff () {
		doc.byTAG("body")[0].style.overflow = 'hidden'; voile_ex.style.display = 'block'; voile_ex.style.opacity = '0';
		for (var iter=0;iter<8;iter++) window.setTimeout("voile.voile_ex().style.opacity='0."+iter+"';",(iter+1)*60);
	}
	function init_base_close (temps) {
		for (var iter=1;iter<9;iter++) window.setTimeout("voile.voile_ex().style.opacity='0."+(8-iter)+"';",(iter*60)+temps);
		var lastop = "voile.voile_ex().style.display='none';doc.byTAG('body')[0].style.overflow = 'auto';";
		window.setTimeout(lastop,480+temps);
	}
	function initPaff (id_node) {
		init_base_aff(); voile_lg1.style.display = 'block';
		for (var iter=1;iter<37;iter++) window.setTimeout("voile.voile_lg1().style.left='"+((iter*10)-360)+"px';",(iter*20)+115);
		window.setTimeout("voile.voile_P_in().style.display='block';",700);
		for (var iter=1;iter<71;iter++) window.setTimeout("voile.voile_P_in().style.width='"+iter*10+"px';",iter*20+700);
		for (var iter=1;iter<41;iter++) window.setTimeout("voile.voile_P_in().style.height='"+iter*10+"px';",iter*20+2100);
		window.setTimeout("voile.voile_af1().style.display='block';doc.byID('"+id_node+"').style.display='block';",2900);
	}
	function initPclose (id_node) {
		if(id_node=="enc1_all") while(doc.byID(id_node).hasChildNodes()) doc.byID(id_node).removeChild(doc.byID(id_node).lastChild);
		doc.byID(id_node).style.display = 'none';
		for (var iter=1;iter<40;iter++) window.setTimeout("voile.voile_P_in().style.height='"+(400-iter*10)+"px';",iter*20+100);
		for (var iter=1;iter<70;iter++) window.setTimeout("voile.voile_P_in().style.width='"+(700-iter*10)+"px';",iter*20+820);
		window.setTimeout("voile.voile_P_in().style.display='none';",2200);
		for (var iter=0;iter<37;iter++) window.setTimeout("voile.voile_lg1().style.left='-"+(iter*10)+"px';",iter*20+2200);
		window.setTimeout("voile.voile_lg1().style.display='none';",2920);
		window.setTimeout("doc.byTAG('body')[0].style.overflow='auto';",2920);
		init_base_close(2315);
	}
	function initPtrans (id1,id2) {
		if(id1=="enc1_all") while(doc.byID(id1).hasChildNodes()) doc.byID(id1).removeChild(doc.byID(id1).lastChild);
		voile_af1.style.display = "none"; doc.byID(id1).style.display = 'none'; doc.byID(id2).style.display = 'block';
		for (var iter=1;iter<40;iter++) window.setTimeout("voile.voile_P_in().style.height='"+(400-iter*10)+"px';",iter*15+100);
		for (var iter=1;iter<70;iter++) window.setTimeout("voile.voile_P_in().style.width='"+(700-iter*10)+"px';",iter*15+685);
		for (var iter=1;iter<71;iter++) window.setTimeout("voile.voile_P_in().style.width='"+iter*10+"px';",iter*15+1720);
		for (var iter=1;iter<41;iter++) window.setTimeout("voile.voile_P_in().style.height='"+iter*10+"px';",iter*15+2770);
		window.setTimeout("voile.voile_af1().style.display='block';",3400);
	}
	function initSaff (choix,id_node) {
		if (choix) init_base_aff();
		voile_lg2.style.display='block'; voile_S_in.style.display='block';
		if (voile_P_in.style.display=='block' && voile_verr.style.display=='none') voile_verr.style.display='block';
		for (var iter=0;iter<12;iter++) {
			var timeout = "voile.voile_lg2().style.opacity='"+(iter/10)+"';";
			window.setTimeout(timeout + "voile.voile_lg2().style.right='"+(390-(iter*30))+"px';",(iter*55)+470);
			window.setTimeout("voile.voile_S_in().style.top='"+(-281+(iter*31))+"px';",(iter*55)+250);
		}
		window.setTimeout("voile.voile_af2().style.display='block';doc.byID('"+id_node+"').style.display='block';",1070);
	}
	function initSclose (choix,id_node,id_after) {
		if(id_node=="enc2_all") while(doc.byID(id_node).hasChildNodes()) doc.byID(id_node).removeChild(doc.byID(id_node).lastChild);
		doc.byID(id_node).style.display = 'none'; voile_af2.style.display = 'none';
		if (voile_P_in.style.display=='block' && voile_verr.style.display=='block') voile_verr.style.display='none';
		for (var iter=0;iter<12;iter++) {
			var timeout = "voile.voile_lg2().style.opacity='"+(1-(iter/10))+"';";
			window.setTimeout(timeout = "voile.voile_lg2().style.right='"+(60+(iter*30))+"px';",50*iter);
			window.setTimeout("voile.voile_S_in().style.top='"+(-31*iter)+"px';",(50*iter)+190);
		}
		window.setTimeout("voile.voile_lg2().style.display='none';",745);
		window.setTimeout("voile.voile_S_in().style.display='none';",745);
		if (choix == 2) init_base_close(470);
		else if (choix == 1) window.setTimeout("voile.initSaff(0,'"+id_after+"');",755);
	}
	function initXaff (id_node) {
		voile_verr.style.display='block'; voile_X_in.style.display='block';
		for (var iter=2;iter<41;iter++) {
			var timeout = "voile.voile_X_in().style.bottom='"+(420-(iter*10))+"px';";
			timeout = timeout+"voile.voile_X_in().style.height='"+(iter*10)+"px';";
			window.setTimeout(timeout+"voile.voile_X_in().style.width='"+(iter*17)+"px';",iter*20);
		}
		window.setTimeout("voile.voile_af3().style.display='block';doc.byID('"+id_node+"').style.display='block';",810);
	}
	function initXclose (id_node) {
		if(id_node=="enc3_all") while(doc.byID(id_node).hasChildNodes()) doc.byID(id_node).removeChild(doc.byID(id_node).lastChild);
		voile_af3.style.display='none'; doc.byID(id_node).style.display = 'none';
		for (var iter=1;iter<40;iter++) {
			var timeout = "voile.voile_X_in().style.bottom='"+(iter*10+20)+"px';";
			timeout = timeout+"voile.voile_X_in().style.height='"+(400-iter*10)+"px';";
			window.setTimeout(timeout+"voile.voile_X_in().style.width='"+(720-iter*20)+"px';",iter*20);
		}
		window.setTimeout("voile.voile_X_in().style.display='none';voile.voile_verr().style.display='none';",800);
	}
	return {
		init: function () {
			voile_ex = doc.byID("voile_ex"); voile_P_in = doc.byID("voile_P_in"); voile_verr = doc.byID("voile_verr");
			voile_X_in = doc.byID("voile_X_in"); voile_S_in = doc.byID("voile_S_in"); voile_af1 = doc.byID("voile_af1");
			voile_af2 = doc.byID("voile_af2"); voile_af3 = doc.byID("voile_af3"); voile_lg1 = doc.byID("voile_lg1");
			voile_lg2 = doc.byID("voile_lg2");
		},
		initPaff: function (id_node) { initPaff(id_node); }, initPclose: function (id_node) { initPclose(id_node); },
		initPtrans: function (id1,id2) { initPtrans(id1,id2); },
		initSaff: function (choix,id_node) { initSaff(choix,id_node); },
		initSclose: function (choix,id_node,id_after) { initSclose(choix,id_node,id_after); },
		initXaff: function (id_node) { initXaff(id_node); }, initXclose: function (id_node) { initXclose(id_node); },
		addElt: function (type_elt,attr_tab,parent_elt) {
			var nodec, type_conv;
			switch (type_elt) { case "titre" : type_conv = "h5"; break;
				case "stitre" : type_conv = "h6"; break; default : type_conv = type_elt; break; }
			if (parent_elt == 0) parent_elt = doc.byID("enc1_all");
			else if (parent_elt == 1) parent_elt = doc.byID("enc2_all");
			else if (parent_elt == 2) parent_elt = doc.byID("enc3_all");
			var retour =  addNodeFun(type_conv,attr_tab,parent_elt); return retour;
		},
		modElt: function (nodec,attr_tab) { modNodeFun(nodec,attr_tab); },
		suppElt: function (nodec) { supNodeFun(nodec); },
		voile_ex: function () { return voile_ex; }, voile_P_in: function () { return voile_P_in; },
		voile_S_in: function () { return voile_S_in; }, voile_X_in: function () { return voile_X_in; },
		voile_af1: function () { return voile_af1; }, voile_af2: function () { return voile_af2; },
		voile_af3: function () { return voile_af3; }, voile_lg1: function () { return voile_lg1; },
		voile_lg2: function () { return voile_lg2; }, voile_verr: function () { return voile_verr; }
	};
})();